<?php require_once('function/check_login_for_index_function.php');?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Health Tracker</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Health Tracker">
    <meta name="author" content="">
	<script>
		function showTab(tab)	{
			document.getElementById("food").style.display= 'none';
			document.getElementById("symptom").style.display= 'none';
			document.getElementById("log").style.display= 'none';
			
			document.getElementById(tab).style.display= 'block';
		}
	</script>
    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
    <link rel="shortcut icon" href="ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
  </head>

  <body onload="showTab('log')">


<?php include_once('nav.php'); ?>

    <div class="container">
    <div class="row">
    <div class="span6">
				<?php 
					if (isset($_SESSION['message'])) {
						foreach ($_SESSION['message'] as $message) {
							echo '<div class="alert">'.constant($message) . '</div>';
						}
						unset($_SESSION['message']);
					} 
				?>
				<?php 
				$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
				if(stripos($ua,'android') !== false) { // && stripos($ua,'mobile') !== false) {
					echo "<div class=\"alert alert-success\">" . constant("MSG_ANDROID") . "</div>";
				}
				?>
				
			<?php 
			
	  			if (isset($_SESSION['session'])) {
				
					if ($user->getRole() === 'doctor') {
						if (intval($user->getVerified()) === intval(false)) {
							echo '<p class="text-error">' . constant("ERROR_DOCTOR_UNVERIFIED") . '</p>';
						}
					}
				
					if (!$user->isValid()) { ?>	
						<p class="text-error"><?php echo constant("ERROR_ACCOUNT_INVALID")?></p>
						<form action="function/form_function.php" method="POST" >
						<label for="token">Token: </label> <input type="text" class="input-small" id="token" name="token" style="margin-top:8px;"/>
						<input type="hidden" id="from" name="from" value="profile"/>
						<button type="submit" name="validateAccount" class="btn btn-primary">Validate</button>
						<button type="submit" name="resendToken" class="btn btn-primary">Resend Token</button>
						</form>
					<?php } ?>
				<?php } ?>
				
      <h1>About Health Tracker</h1>
      <p><?php echo constant("ABOUT_HEALTH_TRACKER") ?> </p>
			<?php if (isset($_SESSION['session'])) { ?>
				<?php if ($user->getRole() === 'patient') {	?>
							<a href="#" onclick="showTab('log')">Log </a> |
							<a href="#" onclick="showTab('food')">Food Diary </a> |
							<a href="#" onclick="showTab('symptom')">Symptom </a>	
				<?php
							echo '<div class="row">';
							echo '<div id="log" class="span4"> <h4> Log </h4>';
							include_once('log_form.php');
							echo '</div>';
							
							echo '<div id="food" class="span4"> <h4> Food Diary </h4>';
							include_once('food_form.php');
							echo '</div>';
							
							echo '<div id="symptom" class="span4"> <h4> Symptom </h4>';
							include_once('symptom_form.php');
							echo '</div></div>';
						}
					}
				?>
    </div>
		<?php if (!isset($_SESSION['session'])) {?>
		<div class="span7" style="background-color: #DCEAF4">
		<a href="signup.php?role=patient"><img src="images/patient.png" />Sign up as patient</a>
		<div class="pull-right" style="padding-right:20px"><a href="signup.php?role=doctor"><img src="images/doctor.png" />Sign up as doctor</a></div>
		</div>
		<?php } else {
                echo '<div class="span5">';
				include_once('notifications_box.php');
                echo '</div>';	
				
            } ?>
			
    </div>
	
    </div> <!-- /container -->

  </body>
</html>
